package io.mft.as.adapter;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;

import io.mft.commons.ioc.MFTSpringUtil;
import io.mft.dev.base.init.MFTFrameworkInitor.MainHostProgramApplicationContextProvider;

public class EventSink {
	static Logger logger = LoggerFactory.getLogger(EventSink.class);
	public static MFTAsApiRuningAdapter adapter;
	
	public static void onStart() {
		onStart(false);
	}
	public static void onStart(boolean devMode) {
		try {
			Thread.currentThread().setContextClassLoader(EventSink.class.getClassLoader());
			MFTAsApiRuningAdapter.initConfig();
			adapter=new MFTAsApiRuningAdapter();
			adapter.start(new MainHostProgramApplicationContextProvider() {
				
				@Override
				public ApplicationContext provide() {
					MFTSpringUtil.initApplicationContext();
					return MFTSpringUtil.getApplicationContext();
				}
			});
			logger.info("MFT-AS适配启动完毕!");
		} catch (Throwable e) {
			logger.error("",e);
		}

	}
	public static void onStop() {
		
	}
}
